import $ from './jquery.js';
export function brandbody() {
    let num = parseInt(Math.random() * 9 + 1);
    //console.log(num)
    num > 4 ? $('.brand-item-body').load('brandbody1.html') : $('.brand-item-body').load('brandbody2.html');
    if (num <= 4) {
        // console.log($('.refresh-btn'))
        $('.refresh-btn').css('display', 'block');

    }

    //设置刷新
    let arr = []

    $('.refresh-btn').click(function () {
        //arr = []
        let timer = null;
        let len = $('.brand-item').length;
        //arr = [];
        let length = parseInt(Math.random() * 5 + 1)
        for (let i = 0; i <= length; i++) {
            let val = parseInt(Math.random() * len)
            if (arr.indexOf(val) == -1) {
                arr.push(val)
            }
        }
        let arr2 = Array.from($('.brand-item img'))
        arr2.forEach(val => {
            $(val).css('transform', '')
        })
        console.log(arr)
        let delay = 0.1;


        arr.forEach(val => {
            delay += 0.1
            $('.brand-item').eq(val).find('img').css('transform', 'rotateY(360deg)');
            $('.brand-item').eq(val).find('img').css('transition-delay', delay + 's');
            $('.brand-item').eq(val).find('img').attr('src', '')
        })

        arr = []
    })
}